package getSum;

public class GetSum {
    // 计算范围内所有偶数的和
    public static long getEvenSum(Long f, Long c) {
        long sum = 0;
        if (f % 2 != 0) {
            f++;
        }
        for (long i = f; i <= c; i += 2) {
            sum += i;
        }
        return sum;
    }

    // 计算范围内所有奇数的和
    public static long getOddSum(Long f, Long c) {
        long sum = 0;
        for (long i = f; i <= c; i++) {
            if (i % 2 != 0) {
                sum += i;
            }
        }
        return sum;
    }
}
